﻿using AutoMapper;
using Domain.Entity.Config;
using Domain.Repository.IConfig;
using Microsoft.AspNetCore.Mvc;

namespace UI.Controllers
{
    public class CMKController : Controller
    {
        private readonly IConfig_major_kindRepository cmAppService;
        private readonly IMapper mapper;

        public CMKController(IConfig_major_kindRepository cmAppService, IMapper mapper)
        {
            this.cmAppService = cmAppService;
            this.mapper = mapper;
        }
        public IActionResult Index()
        {
            return View();
        }

       
        //查询
        [HttpPost("GetCMK")]
        public async Task<IActionResult> GetCMK()
        {
            List<Config_major_kind> cmks = await cmAppService.SelectCMKAsync();
            return Json(cmks);
        }
        //删除
        [HttpPost("DeleteCMK")]
        public async Task<IActionResult> DeleteCMK(int id)
        {
            int i=await cmAppService.DeleteEIAsync(id);
            return Json(i);
        }
        //添加
        [HttpPost("AddCMK")]
        public async Task<IActionResult> AddCMK(Config_major_kind cmk)
        {
            int i=await cmAppService.AddEIAsync(cmk);
            return Json(i);
        }

        [HttpGet]
        public List<Config_major_kind> WenId(int id)
        {
            List<Config_major_kind>li=cmAppService.WenId(id);
            return li;
        }
    }
}
